//
//  LoginRequestTools.m
//  JinFuThree
//
//  Created by 毛韶谦 on 2018/10/8.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "LoginRequestTools.h"

@implementation LoginRequestTools

///finance/app/sendSms
/**
 请求验证码

 @param number 电话号码
 @param success 成功返回
 @param failure 失败返回
 */
+ (void)SendSmsWithPhoneNumber:(NSString *)number Success:(nonnull void (^)(_Nullable id responseObject))success Failure:(nonnull void(^)(_Nullable id responseObject,  NSError * _Nullable error))failure {
    
    NSString *url = [Common ServicesURL:@"finance/app/sendSms"];
    NSDictionary *parameterDic = [NSDictionary dictionaryWithObjectsAndKeys:number, @"mobile", nil];
    [[RequestManager manager] HFQDataCommonRequest_Mao:RequestMethodPost URLString:url parameters:parameterDic success:^(id  _Nullable responseObject) {
        
        NSDictionary *dataDic = responseObject;
        if ([[NSString stringWithFormat:@"%@",dataDic[@"code"]] isEqualToString:@"200"]) {
            success(responseObject);
        }else {
            [HUD_Mao showCharacterMessage:dataDic[@"message"]];
            failure(responseObject, nil);
        }
    } failure:^(id  _Nullable responseObject, NSError * _Nullable error) {
        
        failure(responseObject, error);
    }];
}

//  finance/app/normal/login
/**
 登录请求
 
 @param parameters 参数 电话和验证码
 @param success 成功返回
 @param failure 失败返回
 */
+ (void)LoginWithParameters:(NSDictionary *)parameters  Success:(nonnull void (^)(_Nullable id responseObject))success Failure:(nonnull void(^)(_Nullable id responseObject,  NSError * _Nullable error))failure {
    
    NSString *url = [Common ServicesURL:@"finance/app/normal/login"];
    [[RequestManager manager] HFQDataCommonRequest_Mao:RequestMethodPost URLString:url parameters:parameters success:^(id  _Nullable responseObject) {
        
        NSDictionary *dataDic = responseObject;
        if ([[NSString stringWithFormat:@"%@",dataDic[@"code"]] isEqualToString:@"200"]) {
            success(responseObject);
        }else {
            [HUD_Mao showCharacterMessage:dataDic[@"message"]];
            failure(responseObject, nil);
        }
    } failure:^(id  _Nullable responseObject, NSError * _Nullable error) {
        
        failure(responseObject, error);
    }];
}





@end
